﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace SmallSpider.Dal
{
    public class Dal_Base
    {
        protected readonly string strConnectionString = "Data Source=.;Initial Catalog=SmallSpider;Integrated Security=True";

        private SqlConnection GetConnection()
        {
            SqlConnection conn = new SqlConnection(strConnectionString);
            return conn;
        }

        protected object ExcuteNonQuery_Proc_Return(string procName, SqlParameter[] parameters)
        {
            SqlConnection conn = GetConnection();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = procName;
            for (int i = 0; i < parameters.Length; i++)
            {
                cmd.Parameters.Add(parameters[i]);
            }
            conn.Open();
            int n = cmd.ExecuteNonQuery();
            object o = cmd.Parameters["@RETURN_VALUE"].Value;
            conn.Close();
            return o;
        }


    }
}
